

import Foundation

public struct NDT7TestConstants {

    
    public enum Origin: String, Codable {

        
        case client

        case server
    }

   
    public enum Kind: String, Codable {

        case download

        case upload
    }

    public static let cancelled = "Test cancelled"

    public static let cancelledError = NSError(domain: NDT7WebSocketConstants.domain,
                                               code: 0,
                                               userInfo: [NSLocalizedDescriptionKey: cancelled])
}

public struct NDT7WebSocketConstants {

    public static let domain = "net.measurementlab.NDT7"

   
    public struct MLabServerDiscover {

      
        public static let hostname = "locate.measurementlab.net"

        public static let path = "v2/nearest/ndt/ndt7"

       
        public static let clientName  = "ndt7-client-ios"

       
        public static let url = "https://\(hostname)/\(path)?client_name=\(clientName)"

      
        public static let noMLabServerError = NSError(domain: NDT7WebSocketConstants.domain,
                                                      code: 0,
                                                      userInfo: [NSLocalizedDescriptionKey: "Cannot find a suitable MLab server"])
    }

  
    public struct Request {

       
        public static let headerKey = "Sec-WebSocket-Protocol"

       
        public static let headerProtocolValue = "net.measurementlab.ndt.v7"

        public static let downloadPath = "/ndt/v7/download"

       
        public static let uploadPath = "/ndt/v7/upload"

       
        public static let downloadTimeout: TimeInterval = 15

       
        public static let uploadTimeout: TimeInterval = 15

      
        public static let ioTimeout: TimeInterval = 7

        
        public static let updateInterval: TimeInterval = 0.25

      
        public static let bulkMessageSize = 1 << 13

       
        public static let maxConcurrentMessages: UInt = 100

        public static let uploadRequestDelay: Double = Double(maxConcurrentMessages) * Double(bulkMessageSize) / (4 * 125000) / 100
    }
}
